package ch.hslu.gl20vscpudemo;

import android.content.Context;
import android.graphics.Canvas;
import android.view.MotionEvent;
import android.view.View;

public class OverlayView extends View implements View.OnTouchListener {
	// interface /////////////////////////////////////////////////////////////////
	public interface Callback {
		public void onTouch();
	}

	// members ///////////////////////////////////////////////////////////////////
	private Callback mCallback;

	// constructor ///////////////////////////////////////////////////////////////
	public OverlayView(Context context) {
		super(context);
		mCallback = (Callback)context;

		// register the on touch listener
		setOnTouchListener(this);
	}

	// public methods ////////////////////////////////////////////////////////////
	/** View.OnTouchListener */
	public boolean onTouch(View v, MotionEvent event) {
		switch (event.getAction()) {
			case MotionEvent.ACTION_DOWN:
				mCallback.onTouch();
				return true;
			default:
				return false;
		}
	}

	// protected methods /////////////////////////////////////////////////////////
	/** Override View */
	protected void onDraw(Canvas canvas) {
		/* at the moment nothing */
	}

	/** Override View */
	protected void onSizeChanged(int w, int h, int oldw, int oldh) {
		/* at the moment nothing */
	}
}
